package zb.blog.controller;

import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import zb.blog.base.bean.Result;
import zb.blog.bean.NoticeBean;
import zb.blog.service.INoticeService;

/**
 * @Author: BinZhang
 * @Date: 2018/5/1 15:24
 * @Description:公告相关
 */
@Controller
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private INoticeService iNoticeService;

    @RequestMapping("/getNoticeAll")
    @ResponseBody
    public PageInfo<NoticeBean> getNoticeAll(Integer pageNum, Integer pageSize, String title, Integer enable, String startTime, String endTime) {
        return iNoticeService.getNoticeAll(pageNum, pageSize, title, enable, startTime, endTime);
    }

    @RequestMapping("/back/updateStatusById")
    @ResponseBody
    public Result updateStatusNoticeById(Integer id, Integer status) {
        return iNoticeService.updateStatusNoticeById(id, status);
    }

    @RequestMapping("/back/getNoticeById")
    @ResponseBody
    public Result getNoticeById(Integer id) {
        return iNoticeService.getNoticeById(id);
    }

    @RequestMapping(value = "/back/editNotice", method = RequestMethod.POST)
    @ResponseBody
    public Result editNotice(Integer id, String title, String content, String type, Integer enable) {
        return iNoticeService.editNotice(id, title, content, type, enable);
    }
}
